{extend name="public/base"}

{block name="title"}
销售采购
{/block}
<meta name="format-detection" content="telephone=no">
{block name="style"}
{css href="/static/wechat/css/index.css" /}
{css href="/static/wechat/popo/css/order.css" /}
<style type="text/css">
    .msg_panel{position:fixed;top:0px;left:100%;width:100%;height:100%;background:#fff;overflow:auto;z-index:99;}
    .weui-popup__overlay{opacity:1;}
    .weui-dialog__btn{color:#0bb20c;font-size:0.8rem;}
    .weui-dialog, .weui-toast{box-shadow:0 0 3px 0 #000;}
    #box_deal_list .weui-cell:before{z-index:999;}

</style>
{/block}

{block name="body"}

<div class="pageControl pushOrder bg-f7">
    <div class="nav">
        <div class="msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back_fff"></i></a>
            <h1 class="msui_navTop-title">销售采购</h1>
        </div>
    </div>
    <div id="deal_push_old_but">
        <a class="weui-cell" deal_id="{$repair.id}" phone="{$repair.phone}">
            <div class="weui-label">
                <img src="{$repair.logo|get_img_url}" alt="" />
            </div>
            <div class="weui-cell__bd">
                <p class="cl-3333">我要销售</p>
                <!--<p class="cl-9999">{$repair.phone}</p>-->
            </div>
        </a>
    </div>
    <div class="weui-cell bg-f7">
        <div class="weui-cell__bd">
            最近购买的买家
        </div>
    </div>
    <div id="deal_push_old_list">
        {volist name="order" id="v"}
        <a class="weui-cell" deal_id="{$v.id}" phone="{$v.r_phone}">
            <div class="weui-label">
                <img src="{$v.logo|get_img_url}" alt="" />
            </div>
            <div class="weui-cell__bd">
                <p class="cl-3333">{$v.repair_name|default=''}</p>
                <p class="cl-9999">{$v.phone}</p>
            </div>
        </a>
        {/volist}
    </div>
    <div style="height:2rem;"></div>
</div>

<div style="position:fixed;left:0;bottom:0;z-index:9;width:100%;height:2rem;line-height:2rem;background:#FFAD2C;text-align:center;">
    <a href="javascript:;" style="color:#FFF;float:left;width:49%;" onclick="deal_push_old_but.click();">销售</a>
    <a href="{:url('r_orders/deal_order')}" style="color:#FFF;float:right;width:49%;">订单</a>
</div>


<!--goods_so-->
<div id="deal_push_old" class="msg_panel">
    <div class="pageControl pushOrder">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">我要销售</h1>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-label">
                    <p>对方账户</p>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_phone" type="tel" class="weui-input" placeholder="请输入手机号" />
                </div>
                <!--<a class="weui-cell__ft" href="javascript:;" id="deal_push_old_but">-->
                    <!--<img src="/static/wechat/images/tui_03.jpg" alt=""/>-->
                <!--</a>-->
            </div>
        </div>
        <a href="javascript:;" class="order_btn deal_btn">下一步</a>
    </div>
</div>

<!-- loading toast -->
<div id="loadingToast" style="display:none">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>
<div id="iosDialog2" class="js_dialog" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__bd">弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内</div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" onclick="$('#iosDialog2').hide();" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
        </div>
    </div>
</div>

{/block}


{block name="javascript"}
<script>
//改写原生的对话框
function sAlert(s){
    $('#iosDialog2').show();
    $('#iosDialog2 .weui-dialog__bd').html(s);
}
window.alert = function(s){sAlert(s);}



$(function() {

    //点返回关闭面板
    $('.msui_navTop-back').click(function(){
        $(this).parents('.msg_panel').animate({"left":"100%"});
    });

    //点下一步
    $('.pushOrder .deal_btn').click(function(){
        if($('input[name="s_phone"]').val().length<11){
            alert('请输入正确的手机号');return false;
        }
        if( $('input[name="s_phone"]').val().substr(0,1)!=1 || isNaN($('input[name="s_phone"]').val()) ){
            alert('请输入正确的手机号');return false;
        }
        $('#loadingToast').fadeIn();
        $.ajax({
            type : 'GET',
            url : '{:url("deal_push_so_next")}?phone='+$('input[name="s_phone"]').val(),
            dataType: 'json',
            error: function (d) {
                $('#loadingToast').fadeOut();
                alert('网络异常');
            },
            success: function (d) {
                $('#loadingToast').fadeOut();
                if(d.code==200){
                    if(d.data.id){
                        //var tmpUrl = '{:url("r_orders/server_order_goods")}?order_id='+d.data[0].id;
                        var tmpUrl = '{:url("r_member/deal_push")}?id='+d.data.id;
                        window.location.href = tmpUrl;
                    }else{
                        $.alert(error_code[400060]);
                    }
                }else{
                    var code = d.code;
                    $.alert(error_code[code]);
                }
            }
        });
    });


    //点我要销售
    $("#deal_push_old_but").click(function(){
        $('#deal_push_old').animate({"left":"0px"});
    });
    $('#deal_push_old_list .weui-cell').on("click",function(){
        $('input[name="s_phone"]').val($(this).attr("phone"));
        //$('#deal_push_old').animate({"left":"0"});
        $('.pushOrder .deal_btn').trigger("click");

    });

});
</script>
{/block}